import Fill from "ol/style/Fill";
import Icon from "ol/style/Icon";
import Stroke from "ol/style/Stroke";
import Style from "ol/style/Style";
import Text from "ol/style/Text";
import { transform } from "ol/proj";
import { OverlayManager } from "../manager/overlayManager";
import { MapManager } from "../manager/MapManage";
import { LayerManager } from "../manager/LayerManager";
import { DoubleClickZoom } from "ol/interaction";
import Draw from "ol/interaction/Draw";
import { LayerConstant } from "../manager/LayerConstant";
import VectorSource from "ol/source/Vector";
import VectorLayer from "ol/layer/Vector";
export class InteractionTools {

  constructor(map) {
    this.currentMap = map;
  }
  /**
   * 新增一个绘制交互事件
   * @param layer 绘制的矢量图层
   * @param type 绘制类型
   * @param freehand 是否是徒手多边形
   * @param stopClick 是否阻止默认地图点击、双击事件
   * @param style 矢量图层样式
   */
  addDrawInteraction(layer, type, freehand, stopClick, style) {
    const vectorSource = new VectorSource({});
    let geoFun;
    if (type === "Box") {
      geoFun = Draw.createBox();
      type = "Circle";
    }
    let draw = new Draw({
      source: layer.getSource(),
      type: type,
      freehand: freehand,
      stopClick: stopClick ? stopClick : false,
      style: style,
      geometryFunction: geoFun ? geoFun : undefined,
    });
    this.drawInteraction = draw;
    this.currentMap.addInteraction(this.drawInteraction);
    return this.drawInteraction;
  }
}
